﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        ParseAVE p = null;
        Translate_ave2csp t = null;
        WriteCSP w = null;


        public Form1()
        {
            InitializeComponent();
            if (p == null) {
                p = new ParseAVE();
            }
            
            if (t == null) {
                t = new Translate_ave2csp();
            }

            if (w == null) {
                w = new WriteCSP();
            }

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.openFileDialog.ShowDialog();
            this.textBox1.Text = this.openFileDialog.FileName; 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.saveFileDialog.ShowDialog();
            saveFileDialog.Title = "Specify Destination Filename";
            saveFileDialog.Filter = "txt files (*.txt)|*.txt|doc files (*.docx)|*.*";
            saveFileDialog.FilterIndex = 1;
            saveFileDialog.OverwritePrompt = true;

            if (saveFileDialog.ShowDialog() != DialogResult.Cancel) {

                string name = saveFileDialog.FileName;
                File.WriteAllText(name, "test");
            }
            this.textBox2.Text = this.saveFileDialog.FileName;  

        }

        private void button3_Click(object sender, EventArgs e)
        {
         //   p.setPath(textBox1.Text, textBox2.Text);

            p.setPath("C:\\Users\\cecile\\Desktop\\hello.txt","C:\\Users\\cecile\\Desktop\\copy.txt");
            t.m_fromAVE = p.parse();

            w.m_cspstructure = t.translate();

            w.writeFileAsString("C:\\Users\\cecile\\Desktop\\copy.txt");
        
           // w.writeFileAsString(this.textBox2.Text);
        
            
           }

     
    }
}
